// cmd/server/migrate.go
package main

import (
	"gdrive/config"
	"log"

	"github.com/golang-migrate/migrate/v4"
	_ "github.com/golang-migrate/migrate/v4/database/postgres"
	_ "github.com/golang-migrate/migrate/v4/source/file"
)

func runMigrations(cfg *config.Config) {
	m, err := migrate.New("file://migrations", cfg.DBURL)
	if err != nil {
		log.Fatal("迁移初始化失败:", err)
	}
	defer m.Close()

	if err := m.Up(); err != nil && err != migrate.ErrNoChange {
		log.Fatal("执行迁移失败:", err)
	}

	log.Println("数据库迁移完成")
}
